--Api 表
/*
select * from SYS_Apis
select * from SYS_ApiM --M  Memo Main Manage

ReturnType
返回类型（类似返回值）
1 execSql 
2 openSql
3 execProc(不带返回结果) 
4 openProc(带返回结果集)
5 getList (使用getList sql 模板)
*/

declare 
  @ApiName varchar(50)='sjjd.tree',
  @ReturnType int =5
--
--
delete from SYS_Apis where ApiName=@ApiName
delete from SYS_ApiM where apiName=@ApiName
insert into SYS_ApiM([apiName],[name],[memo])
select @ApiName,'获取审计阶段列表树','获取审计阶段树，API有使用，复核平台使用'
insert into SYS_Apis(ApiName,paramsLen,params,ReturnType,sqlText)
select @ApiName,0,
null,
@ReturnType,
'### select ''all'' as id,null as pid,''全部'' as [text],'''' as dgnd,0 as lx,'''' as jdlx 
### union all
select dgnd as id,''all''as pid,dgnd+''年度''as [text],dgnd,1 as lx,'''' as jdlx from [#(dbname)]..sjjd where isnull(isdeleted,0)=0 group by dgnd 
union all
select jdid as id,case when isnull(pjdmc,'''')='''' then dgnd else dgnd+pjdmc end,jdmc,dgnd,2,jdlx from [#(dbname)]..sjjd where isnull(isdeleted,0)=0
union all
select ''recycleBin'' as id,null as pid,''回收站'' as [text],'''' as dgnd,-1 as lx,''.'' as jdlx
order by id'

/*
### select 'all' as id,null as pid,'全部' as [text],'' as dgnd,0 as lx 
### union all
select dgnd as id,'all'as pid,dgnd+'年度' as [text],dgnd,1 as lx from [#(dbname)]..sjjd where isnull(isdeleted,0)=0 and zcbfid=#para(partID) group by dgnd 
union all
select jdid as id,case when isnull(pjdmc,'''')='''' then dgnd else dgnd+pjdmc end,jdmc,dgnd,2 from [#(dbname)]..sjjd where isnull(isdeleted,0)=0 and zcbfid=#para(partID)
union all
select ''recycleBin'' as id,null as pid,''回收站'' as [text],'''' as dgnd,-1 as lx
order by id

*/
